package com.example.agricultural_big_data.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.agricultural_big_data.service.EmailService;
import com.example.agricultural_big_data.util.LoginRequired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

/**
 * @author xiao yang
 * @Description:
 * @date 2021/3/920:52
 */
@RestController
@CrossOrigin
@RequestMapping("/email")
public class EmailController {

    @Autowired
    EmailService emailService;

    @LoginRequired
    @RequestMapping(value = "/sendCode")
    public JSONObject sendEmail(@RequestBody JSONObject jsonObject){
          return emailService.sendEmail(jsonObject);
    }

    @LoginRequired
    @RequestMapping(value = "/verifyCode")
    public JSONObject verifyCode(@RequestBody JSONObject jsonObject) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        return emailService.verifyCode(jsonObject);
    }

}
